package org.easytouseit.rabbitmq.callback;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;

/**
 * 失败后return回调
 *
 * @author guojm
 * @version V1.0
 * @date 2019-01-02 下午 15:28
 */
public class MsgSendReturnCallback implements RabbitTemplate.ReturnCallback{
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Override
    public void returnedMessage(Message message, int replyCode, String replyText, String exchange, String routingKey) {
        String correlationId = message.getMessageProperties().getCorrelationId();
        logger.info("消息：{} 发送失败, 应答码：{} 原因：{} 交换机: {}  路由键: {}", correlationId, replyCode, replyText, exchange, routingKey);

    }
}
